<html>
	<body>
	
	<form  action="cho_add.php" method = "GET">

		<div>Chief Head Officer Name <input type = "text"  name = "cho_name"></div>
			<div>Pin number <input type = "text"  name = "pin_number"></div>
				Subdistrict <select name="subdistrict_id">
				<option value = "0" > All	</option>
				<option value = "1" > Aburi </option>
				<option value = "2"> Pokrum </option>
	
	</select>
	<input type = "submit" name = "submit" value ="Add">
	</form>
<?php

	//function add(){
		//alert up to say are you sure you want to save
		//yes -> save in databae
		//no -> redirect to  homepage
		//use onclick for this
//	}
	if(!isset($_REQUEST["cho_name"])){
	echo "Empty input";
	exit();
	}
	
	else{
		
	$pin_number = 0;
	if(isset($_REQUEST["pin_number"])){
	$pin_number = $_REQUEST["pin_number"];
	}  
	
	$cho_name = "";
	if(isset($_REQUEST["cho_name"])){
	$cho_name = $_REQUEST["cho_name"];
	}
	
	$subdistrict_id = 0;
	if(isset($_REQUEST["subdistrict_id"])){
	$subdistrict_id = $_REQUEST["subdistrict_id"];
	}
	
	if($subdistrict_id == 0){
	$query = mysql_query("select*from cho");
	}else{
	$query =mysql_query("select * from cho where subdistrict_id = $subdistrict_id");
	}
	
		}
	
		include("cho.php");
	$obj = new cho();
	if(!$obj -> add_cho($cho_name, $subdistrict_id, $pin_number)){
		echo"error";
		echo mysql_error($obj->link);
		exit();
	}
	
	//$row = $obj -> fetch();
	//print_r($row);
	//mysql_query($row,$link);
	
	
	

	
	
	
?>
	
		</table>
	</body>
</html>	
	